<HTML><HEAD><TITLE>?Vars :: ++Domain</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(ic)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>?Vars :: ++Domain</H1>
Constrain Vars to have the domain Domain.
<DL>
<DT><EM>Vars</EM></DT>
<DD>Variable or collection (a la collection_to_list/2) of variables
</DD>
<DT><EM>Domain</EM></DT>
<DD>Domain specification
</DD>
</DL>
<H2>Description</H2>
<P>
   Constrains Vars to take only integer or real values from the domain
   specified by Domain.  Vars may be a variable or a collection of variables
   (as accepted by collection_to_list/2).  Domain can be specified as a
   simple range Lo .. Hi, or as a list of subranges and/or individual
   elements.  Multiple subranges and/or individual elements are allowed in
   integer domains only.  If all subrange bounds and individual elements are
   integers the domain is considered an integer domain and the variables
   Vars are constrained to be integral; otherwise it is considered a real
   domain and the type of the variables is not constrained.  Note that
   infinities are considered to be untyped for this purpose.
<P>
   For instance:
<PRE>
     X :: 0..1                  % boolean
     X :: -1..5                 % integer between -1 and 5
     X :: 1..inf                % strictly positive integer
     X :: 0.0..10.0             % real between 0.0 and 10.0
     X :: 1.5..3.7              % real between 1.5 and 3.7
     X :: 0.0..5                % real between 0.0 and 5.0
     X :: 1.4__1.6..3.6__3.8    % real where the bounds aren't known exactly
     X :: breal(0)..inf         % nonnegative real
     X :: [0..3, 5, 8..10]      % any integer from 0 to 10 except 4 and 6
     [X, Y, Z] :: 1..8          % apply domain to X, Y and Z
     M[2..4, 5] :: 1..8         % apply to rows 2..4, column 5 of matrix M
     X :: [0.0..5.0, 7.0..9.0]  % Type error
     X :: [a, b, c]             % Type error
</PRE>

<H2>Examples</H2>
<PRE>[eclipse 2]: X :: 0..1.
X = X{[0, 1]}
Yes (0.00s cpu)

[eclipse 3]: X :: -1..5.
X = X{-1 .. 5}
Yes (0.00s cpu)

[eclipse 4]: X :: 1..inf.
X = X{1 .. 1.0Inf}
Yes (0.00s cpu)

[eclipse 5]: X :: 0.0..10.0.
X = X{0.0 .. 10.0}
Yes (0.00s cpu)

[eclipse 6]: X :: 1.5..3.7.
X = X{1.5 .. 3.7}
Yes (0.00s cpu)

[eclipse 7]: X :: 1.4__1.6..3.6__3.8.
X = X{1.4 .. 3.8}
Delayed goals:
        ic : (-(X{1.4 .. 3.8}) =&lt; -1.6__-1.4)
        ic : (X{1.4 .. 3.8} =&lt; 3.6__3.8)
Yes (0.00s cpu)

[eclipse 8]: X :: [0..3, 5, 8..10].
X = X{[0 .. 3, 5, 8 .. 10]}
Yes (0.00s cpu)
</PRE>
<H2>See Also</H2>
<A HREF="../../lib/ic/integers-1.html">integers / 1</A>, <A HREF="../../lib/ic/reals-1.html">reals / 1</A>, <A HREF="../../lib/suspend/NN-2.html">suspend : :: / 2</A>, <A HREF="../../lib/ic_sets/NN-2.html">ic_sets : :: / 2</A>, <A HREF="../../lib/fd_sets/NN-2.html">fd_sets : :: / 2</A>, <A HREF="../../lib/fd/NN-2.html">fd : :: / 2</A>, <A HREF="../../lib/ic_hybrid_sets/NN-2.html">ic_hybrid_sets : :: / 2</A>, <A HREF="../../lib/eplex/NN-2.html">eplex : :: / 2</A>, <A HREF="../../lib/ic/NN-3.html">:: / 3</A>, <A HREF="../../lib/ic/HNN-2.html">#:: / 2</A>, <A HREF="../../lib/ic/SNN-2.html">$:: / 2</A>
</BODY></HTML>
